home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Acorn User: The Risc OS Music Utilities CD
/
Acorn User: The Risc OS Music Utilities CD.iso
/
ARGONET
/
REPLAYER.SPK
/
h
/
replayer
< prev
Wrap
Text File
|
1998-09-04
|
6KB
|
177 lines
/* replayer.h */
/* A portable interface for playing Replay file. */
#ifndef lib_replayer_H
#define lib_replayer_H
#include <stdlib.h>
#include <stdio.h>
#include "Dreamscape:bool.h"
#include "replaydriver.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct replayer_file replayer_file;
typedef struct replayer_header replayer_header;
typedef struct replayer_soundtrack_info replayer_soundtrack_info;
typedef struct replayer_sound_driver_info replayer_sound_driver_info;
typedef struct replayer_chunk_entry replayer_chunk_entry;
/* The structure is declared here to be shared across files, but its
contents are *private* and you must not rely on them. */
struct replayer_file {
/* Basic information about file */
char *filename;
replayer_header *header;
replayer_chunk_entry *chunks;
/* Playback preferences. */
char quality; /* 1--4 */
unsigned skip_late_data: 1;
#ifndef replayer_NO_BACKWARDS
unsigned backwards: 1;
#endif
/* Data for sound playing */
replaydriver_driver *driver;
replaydriver_control *control;
replaydriver_buffer *buffer;
int file; /* OSLib is broken: os_f should not be a byte. */
int current_chunk; /* The next chunk to be read from the file. */
int track_playing; /* The track number we're playing (usually 0). */
unsigned playing: 1; /* Whether we're playing sound or not. */
unsigned next_buffer: 1; /* The buffer that will be empty next (0 or 1). */
};
/* Pointers here can't be const unfortunately, otherwise I can't
delete them. */
struct replayer_header {
char *title, *date_and_copyright, *other_details;
/* Video info. */
char *video_type;
int width, height, colour_depth, fps;
/* Soundtracks info. */
int no_soundtracks;
replayer_soundtrack_info *soundtracks;
int no_chunks, /* Number of chunks - 1 */
frames_per_chunk;
int even_chunk_size, odd_chunk_size;
int chunk_catalogue; /* Offset in file to chunk catalogue. */
int sprite_offset, sprite_size; /* Sprite info. */
int key_frames_offset;
};
struct replayer_soundtrack_info {
int type_number;
char *type; /* For type 2, this is contains the leafname of the driver,
otherwise it contains the whole header line. */
double rate; /* Converted to Hz for you. */
int channels, precision;
unsigned reverse_channels: 1;
unsigned linear_sound: 1;
unsigned unsigned_sound: 1;
unsigned adpcm_sound: 1;
};
struct replayer_sound_driver_info {
char *name, *copyright;
/* If 0, playback can only start at the beginning of a chunk;
if 1, playback can start at any sample in a chunk;
other values reserved. */
int start_anywhere;
/* This is distinct from the number of bits given in the soundtrack info.
This talks about the decompression buffer, not the sample buffer you
supply the driver with filled. */
int precision;
/* For these, see section 10 of ToUseSound: */
unsigned variable_ratio: 1; /* Set if no constant bits/sample ratio. */
double max_sample_bits; /* Max size of a compressed sample, in bits. */
int buffer_overhead; /* Overhead for From16 buffer, per channel. */
};
struct replayer_chunk_entry {
int offset, video_size, sound_size[1];
};
#define replayer_chunk_entry_SIZE(channels) \
(sizeof(int) * 2 + sizeof(int) * channels)
/* Initialisation/finalisation methods. */
replayer_file *replayer_create_file(const char *filename);
void replayer_destroy(replayer_file *obj);
/* Methods for reading essential information. */
const replayer_header *replayer_get_header(const replayer_file *obj);
const replayer_chunk_entry *replayer_get_chunk_catalogue
(const replayer_file *obj);
int replayer_get_length(const replayer_file *obj);
/* Reading info about sound drivers. */
replayer_sound_driver_info *replayer_get_driver_info_from_soundtrack
(const replayer_soundtrack_info *info);
replayer_sound_driver_info *replayer_get_driver_info_type2(const char *name);
void replayer_free_driver_info(replayer_sound_driver_info *info);
/* Preferences for playing sound. */
void replayer_set_sound_quality(replayer_file *obj, int quality /* 1--4 */);
void replayer_set_skip_late_data(replayer_file *obj, bool skip);
/* Methods dealing with playing the file. */
char *replayer_get_driver_filename(const replayer_soundtrack_info *info);
char *replayer_obj_get_driver_filename(const replayer_file *obj, int track);
#define replayer_play_ALLOC_ERROR 1 /* Couldn't allocate */
#define replayer_play_DRIVER_ERROR 2 /* Couldn't load driver */
#define replayer_play_FORMAT_ERROR 3 /* File unsuitable */
#define replayer_play_FILE_ERROR 4 /* Couldn't open file */
int replayer_sound_play(replayer_file *obj, int track);
void replayer_sound_stop(replayer_file *obj);
void replayer_sound_tidy(replayer_file *obj);
/* Method for feeding hungry sound drivers. */
#define replayer_feed_FINISHED -2
#define replayer_feed_SUCCESS -1
#define replayer_feed_FILE_ERROR 1
#define replayer_feed_ALLOC_ERROR 2
#define replayer_feed_FATAL 3
int replayer_sound_feed(replayer_file *obj);
const int *replayer_get_poll_word(replayer_file *obj);
/* Methods for inflight entertainment. */
int replayer_sound_set_pause(replayer_file *obj, bool flag);
bool replayer_sound_get_pause(const replayer_file *obj);
int replayer_sound_set_mute(replayer_file *obj, bool flag);
bool replayer_sound_get_mute(const replayer_file *obj);
int replayer_sound_get_time(const replayer_file *obj);
#ifndef replayer_NO_BACKWARDS
/* For playing sound backwards! */
int replayer_set_backwards(replayer_file *obj, bool flag);
bool replayer_get_backwards(const replayer_file *obj);
#endif
/* Low-level structures and internal functions. */
char *replayer_read_header_line(FILE *file);
int replayer_read_header_number(FILE *file);
#ifdef __cplusplus
}
#endif
#endif